new Vue({
	el: "body",
	data: {
		username: "",
		phonenum: "",
		mypassword: "",
        myadress:""
	},
	created: function() {
		this.leancloudInit();
	},
	methods: {
		leancloudInit: function() {
			var APP_ID = 'c4w6bVvWfh8xxcmkBE1G0gIt-gzGzoHsz';
			var APP_KEY = 'JBikg4Ksk76zcTi5BKYWvTJF';
			AV.init({
				appId: APP_ID,
				appKey: APP_KEY
			});
		},
		zc: function() {
			var _this = this;
			// 新建 AVUser 对象实例
			var user = new AV.User();
			// 设置用户名
			user.setUsername(_this.phonenum);
			// 设置密码
			user.setPassword(_this.mypassword);
			// 设置邮箱
			user.signUp().then(function(loginedUser) {
				AV.User.logIn(_this.phonenum, _this.mypassword).then(function(loginedUser) {
					var Product = AV.Object.extend('ELM_user');
					var product = new Product();
					product.set('money', '0');
					product.set('rotate_num', '0');
					product.set('Coupon', '[]');
					product.set('username', _this.username);
					product.set('ifnewuser', 'true');
					product.set('phonenum', _this.phonenum);
					product.set('integral', '0');
					product.set('adress', "['"+_this.myadress+"']");
					product.save().then(function() {
						//  发布成功
						location.href="../index/index.html"
					}, function(error) {
						alert("添加失败");
					});
				}, function(error) {
					console.log("请正确输入用户名密码");
				});
			}, function(error) {
				alert("注册失败");
			});
		},
		backpage:function(){
			history.back();
		}
	}

})